﻿@using HCMS.Dictionary
@using HCMS.Extensions
@{
    Layout = "~/Views/Shared/_Layout_Edit_Pear_Layui.cshtml";

    var fromId = ViewContext.HttpContext.Request.Query["fromId"].ToInt(0);
}

<div class="layui-card">
    <div class="layui-card-body">
        <table id="tableList" lay-filter="tableList"></table>

        <div class="layui-form-item layui-fixbar btn-fixbar-box">
            <div class="layui-input-block">
                <button type="button" class="layui-btn layui-btn-primary layui-border-red" lay-on="close">
                    <i class="layui-icon layui-icon-close"></i>关闭
                </button>
            </div>
        </div>
    </div>
</div>

@section Scripts {
    <script>
        var fromId = '@fromId';
        layui.use(['table', 'jquery', 'util'], function () {
            let table = layui.table;
            let $ = layui.jquery;
            let util = layui.util;

            loadList();

            // 列表
            function loadList() {
                table.render({
                    elem: '#tableList',
                    url: '/oauth2app/accesstokenlist/',
                    method: 'post',
                    where: getQueryParams(),
                    height: 'full',
                    page: true,
                    cols: [[
                        { field: 'id', title: 'ID', width: 80 },
                        { field: 'createTime', title: '创建 时间', align: 'center', width: 160, templet: function (d) { return util.toDateString(d.createTime); } },
                        { field: 'expirationTime', title: '过期 时间', align: 'center', width: 160, templet: function (d) { return util.toDateString(d.expirationTime); } },
                        { field: 'token', title: 'Token' }
                    ]],
                    skin: 'line',
                    defaultToolbar: [{
                        title: '刷新',
                        layEvent: 'refresh',
                        icon: 'layui-icon-refresh',
                    }, 'filter']
                });
            }

            // 搜索条件
            function getQueryParams() {
                return {
                    fromId: fromId,
                };
            }
        });
    </script>
}